﻿	      <?php include("conn.php");
             mysql_query('SET NAMES UTF8'); 

	  

class MyPrizeBean
{

	public $name;
	public $shopid;
	public $com;
	public $carid;
	public $zongjia;

	function __construct($name,$shopid,$com,$carid,$zongjia)
	{
	
		$this->name      = $name;
		$this->shopid    = $shopid;
		$this->com    = $com;
		$this->carid    = $carid;
		$this->zongjia    = $zongjia;
	}
}




   if($_POST["sid"]!="")
   {
   $de=$_POST["sid"]*30;
   }
    else
	{
	$de=0;
	}
	$uid=$_REQUEST[userid];
	$state=1;
	$state2=3;
	
	$zongj=0;
	$rert30=mysql_query("select *from car where userid='".$uid."' and state='".$state."' ");
	 $i=0;
	 $contents="";
	while($rowf=mysql_fetch_array($rert30)){
	
	$zongj=$zongj+$rowf[price]*$rowf[number];
	
	}
	
		$rert30=mysql_query("select DISTINCT (shopid) from car where userid='".$uid."' and (state='".$state."'or state='".$state2."') order by carid desc limit $de,30");
	
	$prize = array();
	
	while($rowf=mysql_fetch_array($rert30)){
	

    

 $rert32=mysql_query("select *from shop where  shopid ='".$rowf[shopid]."'");
$rowf2=mysql_fetch_array($rert32);

     $contents.="<div class='commodity'><div class='top'><i class='circle'></i><b></b><p>'".$rowf2[name]."'></p></div>";

      
        $rert36=mysql_query("select *from car where userid='".$uid."' and (state='".$state."'or state='".$state2."') and shopid ='".$rowf[shopid]."' order by carid desc");

	while($rowf6=mysql_fetch_array($rert36)){

		$rert31=mysql_query("select *from goods where  goodsid ='".$rowf6[goodsid]."'");
$rowf1=mysql_fetch_array($rert31);

$st1=1;
		$rert33=mysql_query("select * from goodsimages where  goodsid ='".$rowf1[goodsid]."' and state='".$st1."' order by id desc limit 0,1");
		$rowf3=mysql_fetch_array($rert33);
		
		$contents.="<span class=\"yinc\" id='a".$i."'>".$rowf6['carid']."</span><div class='bottom'><i class='circle-1'></i><img src='http://www.ddjjmall.com/api/".$rowf3['images']."' width='93' height='auto' alt=''><div><p><b class='minus'><i></i></b><span class='num'>".$rowf6['number']."</span><b class='add'><i></i><i></i></b></p><p>".$rowf1['title']."</p><p>选项：".$rowf6['chicun'].$rowf6['caizhi']."</p></div></div><span class=\"yinc\" id='".$i."'>".$rowf6['carid']."</span>";

$i++;
		
}

$contents.="</div>";


}	

$prize[] = new MyPrizeBean($rowf2['name'],$rowf[shopid],$contents,$rowf['carid'],$zongj);
		


echo json_encode($prize);


?>